package thread2;


import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class cp1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
            }
            System.out.println(Thread.currentThread().getName());
            System.out.println("run end ...");
        });
        future.get();


        CompletableFuture<Integer> future1 = CompletableFuture.supplyAsync(() -> {
            return 12;
        });

        System.out.println(future1.get());
        System.out.println(future1.join());;


    }
}
